/**
 * 
 */
package com.wechat.service.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wechat.service.quartz.service.ITriggerUtil;



/**
 * @author tj
 *
 */
public class QuartzController {
	//private final static Logger log = LoggerFactory.getLogger(QuartzController.class);
    @Autowired
    private ITriggerUtil triggerUtil;
	
    /**
     * 修改Cron表达式
     * @param newCron
     * @param jobId
     * @return
     */
    @RequestMapping("/updateCron")
    @ResponseBody
    public Object quartz(String newCron,String jobId) {
    	try {
			triggerUtil.updateCron(newCron, jobId);
		} catch (Exception e) {
			 return e.getMessage();
		}
        return "success";
    }

    /**
     * 启动或停止一个任务
     * @param boo
     * @param jobId
     * @return
     */
    @RequestMapping("/startOrStop")
    @ResponseBody
    public Object quartz(Boolean boo,String jobId) {
    	try {
    		triggerUtil.updateRunStatus(boo, jobId);
		} catch (Exception e) {
			 return e.getMessage();
		}
        return "success";
    }
}
